package cn.com.headfree.base.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import cn.com.headfree.base.initdata.InitCacheData;

//@WebListener
public class InitContextDataListener implements ServletContextListener {
    // 启动运行日志
    /** log */
    private static final Logger log = LogManager.getLogger(InitContextDataListener.class);

    public void contextDestroyed(ServletContextEvent context) {
    }

    public void contextInitialized(ServletContextEvent context) {
        WebApplicationContext app = WebApplicationContextUtils.getWebApplicationContext(context.getServletContext());
        log.info("***********************开始初始化数据*****************************");
        InitCacheData.getInstance().initData(app);
        log.info("***********************初始化数据完成*****************************");
    }
}
